
require(['select2', 'date','validator','jquery-form'], function() {
	var $formData = $('#formData');
	$formData.initForm();

	add = function(fn) {
		addOrUpdate("/upgrade/addPerMgr.htm",fn);
	};

	function addOrUpdate(url,callBack){
		var result = $.validator($formData);
		if(result){
			var params = [];
			$formData.find('input[name="paramName"]').each(function(i,item){
			params.push({
				name  : "list["+ i + "].paramName",
				value : $(this).attr("id")
			});
			params.push({
				name  : "list["+ i + "].paramValue",
				value : $(this).val()
			});
			params.push({
				name  : "list["+ i + "].sn",
				value : i
			});
		});
		params.push({
			name  : "carId",
			value : commonFun.getLeftTreeSelectedNodes()[0].id
		},{
			name  : "vrsnName",
			value : $("#vrsnName").val()
		},{
			name  : "remark",
			value :  $("#remark").val()
		},{
			name  : "vrsnType",
			value : "VERS0004"
		});
		$.ajaxExt({
			url : url,
			data : params
		}).done(function(){
			callBack();
		});
		/*	$formData.ajaxSubmit({
				dataType : 'JSON',
				success : function(result){
					if (result && result.msgType) {
						if (result.msgType && result.msgType == '2') {
							$.messager.alert("警告", result.warnMsg || "系统异常", "warning");
						} else if (result.msgType && result.msgType == '3') {
							$.messager.alert("错误", result.errorMsg || "系统异常", "error");
						}else if (result.msgType && result.msgType == '1') {
							callBack()
						}
					}else{

					}
				},
				error : function() {
					$.messager.alert("错误", "系统异常", "error");
				}
			});*/
		}
	}

});